<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            height: 100%;
        }

        #app {
            height: 100%;
            background-color: bisque;
            display: flex;
            flex-direction: column;
        }

        .title,
        p {
            text-align: center;
            color: brown;
        }

        .title {
            font-size: 18px;
            font-weight: 700;
            line-height: 50px;
        }

        p {
            width: 90%;
            margin: 0 auto;
            font-size: 12px;
            padding-bottom: 10px;
            border-bottom: 5px solid rgba(197, 122, 89, 0.959);
        }

        .content {
            flex: 1;
            padding: 0 10px;
        }

        .item {
            background-color: white;
            margin: 10px 0;
            border-radius: 10px;
            display: flex;
            padding: 15px;
            align-items: center;
            position: relative;
        }

        .item .left {
            width: 40px;
            border-radius: 50%;
            overflow: hidden;
        }

        .item .left img {
            width: 100%;
        }

        .item .center {
            margin-left: 10px;
        }

        .item .center .name {
            font-size: 14px;
            color: rgb(113, 69, 50);
        }

        .item .center .intro {
            font-size: 12px;
            color: brown;
        }

        .item .right {
            float: right;
            position: absolute;
            right: 15px;
        }

        .item .right button {
            padding: 2px 5px;
            border-radius: 20px;
            border: 2px solid brown;
            background-color: rgb(255, 213, 0);
            color: brown;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="title">任务列表</div>
        <p>每完成一个任务，即可获得10MB~ 1GB流量哦!</p>
        <div class="content">
            <div class="item" v-for="(item,index) in datalist">
                <div class="left">
                    <img v-bind:src="item.pic" alt="">
                </div>
                <div class="center">
                    <div class="name">{{item.name}}</div>
                    <div class="intro">{{item.intro}}</div>
                </div>
                <div class="right">
                    <button v-on:click="changeState(item)">{{item.state == 1 ? '去完成' : (item.state == 2 ? '去领取' :
                        '已领取')}}</button>
                </div>
            </div>
        </div>
    </div>
</body>

</html>
<script src="./vue-2.5.21.js"></script>
<script>

    new Vue({
        el: '#app',
        data: {
            datalist: [
                { id: 1, pic: './img/1.png', name: '咪咕视频送流量', intro: '来咪咕视频，每月领500MB流量奖励', state: 1 },
                { id: 2, pic: './img/2.png', name: '和彩云送福利', intro: '免费领100G空间+月月2GB', state: 1 },
                { id: 3, pic: './img/3.png', name: '最高40元套餐折扣券', intro: '参与抽奖，奖励10MB，经验值+10', state: 1 },
                { id: 4, pic: './img/4.png', name: '吃喝玩乐季，超级秒杀', intro: '进入隐藏二楼参与秒杀，奖励10MB', state: 1 },
            ]
        },
        methods: {
            changeState(item) {
                if (item.state == 1) {
                    item.state = 2
                } else if(item.state == 2) {
                    item.state = 3
                }
            }
        }
    })

</script>